package com.jysz.certificate.persistence.dao;

import java.io.Serializable;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate3.SessionFactoryUtils;
import com.jysz.webcore.ssh.orm.hibernate.HibernateDao;

/**
 * 连接sqlserver的dao。没做自动事务支持。。
 * @author kacarich email:javaengine@outlook.com
 *
 * @param <T>
 * @param <PK>
 */
public abstract class AbstractSqlServerDao<T, PK extends Serializable> extends HibernateDao<T, PK> {

	@Autowired 
	@Qualifier("sqlServerSessionFactory")
	private SessionFactory sessionFactory;
	
	@Override
	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}
	
	/**
	 * @return
	 */
	@Override
	public Session getSession() {
		return SessionFactoryUtils.getSession(sessionFactory, true);
	}
}
